//
//  YMSampleCameraAgainVC.m
//  YMMedical
//
//  Created by y s on 2023/7/24.
//

#import "YMSampleCameraAgainVC.h"
#import "YMCheckInformationModel.h"

@interface YMSampleCameraAgainVC ()

@property (nonatomic, strong) UIScrollView *svMain;
@property (nonatomic, strong) UIView *vBg;

@property (nonatomic, strong) UILabel *lblTips;
@property (nonatomic, strong) UIImageView *imgvTop;
@property (nonatomic, strong) UILabel *lblMark;
@property (nonatomic, strong) UILabel *lblError;

@property (nonatomic, strong) UIButton *btnFinish;

@end

@implementation YMSampleCameraAgainVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setUI];
}

- (void)setUI{
    [self showNavTitle:KLanguage(@"re_camera_txt")];
    [SNavUtil rightIcon:self icon:@"tools_nav_home_icon" onClick:^{
        [YMBridging goHomeTabWithAlert];
    }];
    [self.view addSubview:self.svMain];
    [self.svMain addSubview:self.vBg];
    [self.vBg addSubview:self.lblTips];
    [self.vBg addSubview:self.imgvTop];
    [self.vBg addSubview:self.lblMark];
    [self.vBg addSubview:self.lblError];
    [self.view addSubview:self.btnFinish];
    
    [self.svMain mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo([SFitUtil fit:15]);
        make.right.mas_equalTo([SFitUtil fit:-15]);
        make.top.mas_equalTo([SFitUtil fit:15]);
    }];
    [self.vBg mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.top.mas_equalTo(0);
        make.width.equalTo(self.svMain);
        make.bottom.mas_equalTo(0);
    }];
    [self.lblTips mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo([SFitUtil fit:15]);
        make.right.mas_equalTo([SFitUtil fit:-15]);
        make.top.mas_equalTo([SFitUtil fit:15]);
    }];
    [self.imgvTop mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.lblTips.mas_bottom).offset([SFitUtil fit:79]);
        make.size.mas_equalTo([SFitUtil fitSize:140 height:140]);
        make.centerX.mas_equalTo(0);
    }];
    [self.lblMark mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.imgvTop.mas_bottom).offset([SFitUtil fit:4]);
        make.left.mas_equalTo([SFitUtil fit:15]);
        make.right.mas_equalTo([SFitUtil fit:-15]);
    }];
    [self.lblError mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.lblMark.mas_bottom).offset([SFitUtil fit:45]);
        make.bottom.mas_equalTo([SFitUtil fit:-15]);
        make.left.mas_equalTo([SFitUtil fit:15]);
        make.right.mas_equalTo([SFitUtil fit:-15]);
    }];
    [self.btnFinish mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(-IPHONE_X_BOTTOM_HEIGHT-[SFitUtil fit:15]);
        make.size.mas_equalTo([SFitUtil fitSize:345 height:54]);
        make.centerX.mas_equalTo(0);
        make.top.equalTo(self.svMain.mas_bottom).offset([SFitUtil fit:30]);
    }];
}


- (void)finishClickAction:(id)sender{
    YMCameraViewController *vc = [[YMCameraViewController alloc] init];
    vc.dictInfor = [self.checkModel getCheckInforData];
    vc.finishBlock = self.finishBlock;
    vc.modalPresentationStyle = UIModalPresentationFullScreen;
    [SJumpUtil presentVC:vc animated:YES];
}

#pragma mark -- setter and getter
- (UIScrollView *)svMain{
    if (_svMain == nil){
        _svMain = [[UIScrollView alloc] init];
        _svMain.showsVerticalScrollIndicator = YES;
        _svMain.showsHorizontalScrollIndicator = NO;
        _svMain.clipsToBounds = YES;
        _svMain.layer.cornerRadius = [SFitUtil fit:8];
    }
    return _svMain;
}
- (UIView *)vBg{
    if (_vBg == nil){
        _vBg = [[UIView alloc] init];
        _vBg.backgroundColor = STheme.D9;
        _vBg.clipsToBounds = YES;
        _vBg.layer.cornerRadius = [SFitUtil fit:8];
    }
    return _vBg;
}
- (UILabel *)lblTips{
    if (_lblTips == nil){
        _lblTips = [SThemeUtil boldLabel:@"" color:STheme.H_D1 fontSize:16];
        _lblTips.numberOfLines = 0;
        
        NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
        style.lineSpacing = [SFitUtil fit:8];
        NSAttributedString *attr = [[NSAttributedString alloc] initWithString:KLanguage(@"sampling_failure_hint") attributes:@{NSParagraphStyleAttributeName: style}];
        _lblTips.attributedText = attr;
        _lblTips.textAlignment = NSTextAlignmentCenter;
    }
    return _lblTips;
}
- (UIImageView *)imgvTop{
    if (_imgvTop == nil){
        _imgvTop = [[UIImageView alloc] init];
        _imgvTop.image = [UIImage imageNamed:@"check_sample_photo_again"];
    }
    return _imgvTop;
}
- (UILabel *)lblMark{
    if (_lblMark == nil){
        _lblMark = [SThemeUtil label:@"" color:STheme.H_D3 fontSize:16];
        _lblMark.numberOfLines = 0;
        
        NSMutableParagraphStyle *style = [[NSMutableParagraphStyle alloc] init];
        style.lineSpacing = [SFitUtil fit:8];
        NSAttributedString *attr = [[NSAttributedString alloc] initWithString:KLanguage(@"sampling_bottom_txt") attributes:@{NSParagraphStyleAttributeName: style}];
        _lblMark.attributedText = attr;
        _lblMark.textAlignment = NSTextAlignmentCenter;
    }
    return _lblMark;
}
- (UILabel *)lblError{
    if (_lblError == nil){
        _lblError = [SThemeUtil label:@"" color:0xFF3141 fontSize:16];
        _lblError.numberOfLines = 0;
        _lblError.textAlignment = NSTextAlignmentCenter;
        _lblError.text = KLanguage(@"camera_exc_txt");
    }
    return _lblError;
}

- (UIButton *)btnFinish{
    if (_btnFinish == nil){
        _btnFinish = [UIButton buttonWithType:UIButtonTypeCustom];
        [_btnFinish setTitle:KLanguage(@"re_camera_txt") forState:UIControlStateNormal];
        [_btnFinish setTitleColor:STheme.D9 forState:UIControlStateNormal];
        _btnFinish.titleLabel.font = [SFitUtil fitBoldFont:16];
        [_btnFinish addTarget:self action:@selector(finishClickAction:) forControlEvents:UIControlEventTouchUpInside];
        _btnFinish.backgroundColor = STheme.D12;
        _btnFinish.layer.cornerRadius = [SFitUtil fit:10];
        _btnFinish.clipsToBounds = YES;
    }
    return _btnFinish;
}

@end
